/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package aybolit.core.objects.dao.impl;

import aybolit.core.objects.dao.HealthingDiagnosysDao;
import aybolit.core.objects.model.HealingDiagnosis;
import java.io.Serializable;
import java.util.List;
import javax.annotation.Resource;
import org.hibernate.SessionFactory;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * @author Masumov Emin
 */
@Transactional
public class HealthingDiagnosysDaoImp implements HealthingDiagnosysDao, Serializable {

    SessionFactory sessionFactory;

    @Transactional
    @Override
    public List<HealingDiagnosis> findAllHealthingDiagnosysBypacientId(String id) {
        return sessionFactory.getCurrentSession().getNamedQuery("HealingDiagnosis.findHealingDiagnosisByPacientId").setParameter("h_id", Integer.parseInt(id)).list();
    }

    @Resource(name = "sessionFactory")
    public void setSessionFactory(SessionFactory sessionFactory) {
        this.sessionFactory = sessionFactory;
    }

    @Override
    public void save(HealingDiagnosis hd) {
      sessionFactory.getCurrentSession().save(hd);
    }
}
